<?php
namespace DRY\Render;

/**
 * DonReY Framework 2012 :: Render Transform - General XML Writer
 * Generates valid XML string using \DRY\Module\XML, from various types of PHP compound variables. Also suports "humanizing" of output by using indentation
 * Right now supports SimpleXMLElement and array as input data.
 *
 * @author Wavetrex <wavetrex@gmail.com>
 * @link http://www.donrey.net/Documentation/Structure/Modules/Render/xmlwriter.html
 * @license [GPL v3] http://www.gnu.org/licenses/gpl-3.0.html
 * @version 1.0.dev
 * @package DonReY
 * @subpackage Module.Render
 */
class Transform_Xmlwriter implements Transform_base
{

	/**
	 * Generates valid XML.
	 *
	 * @param array|SimpleXMLElement $data
	 */
	public function render_String($data, $doctype = null, $humanize = true)
	{
		\DRY\Module\XML::init_XMLWriter(null, $doctype, $humanize);
		if($data instanceof \SimpleXMLElement)
			\DRY\Module\XML::from_SimpleXML($data);
		elseif(is_array($data))
			\DRY\Module\XML::from_Array($data, 'xml');

		return \DRY\Module\XML::write_XML();
	}

	/**
	 * @see DRY_Render_Transform_base::__toString()
	 */
	public function __toString()
	{
	}
}